#ifndef CHESS_BASE
#define CHESS_BASE

#include "move.hpp"
#include <vector>
#include <string>
#include <memory>

class Board;

enum Camp {
    RED, BLACK
};

Camp operator!(const Camp &c);

// 抽象基类
class ChessPiece {
public:
    enum Type {
        KING,   // 将
        ROCK,   // 車
        CANNON, // 炮
        KNIGHT, // 马
        GUARD,  // 士
        BISHOP, // 象
        PAWN,   // 兵
    };

    Type type() const { return _type; }
    Camp camp() const { return _camp; }
    bool is_available(const Board &board, const Move &move) const;
    virtual std::vector<Move> available_move(const Board &board, const Location loc) const = 0;
    virtual std::shared_ptr<ChessPiece> clone() const = 0;

    static std::shared_ptr<ChessPiece> parse(std::string str, Camp camp);
protected:
    ChessPiece(const Type type, const Camp camp): _type(type), _camp(camp) { }
    const Type _type;
    const Camp _camp;
};

#endif